package com.cx.bank.servlet.admin;

import com.cx.bank.handler.MyInVocationHandler;
import com.cx.bank.manager.IManager;
import com.cx.bank.manager.ManagerImpl;
import com.cx.bank.pojo.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

/**
 * 跳转到更新user页面
 * @author jxau_scf
 * @date 2021/8/5 - 14:32
 */
@WebServlet(urlPatterns = "/user/toUpdateUser")
public class ToUpdateUserServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //拿到请求参数userId
        String userId = req.getParameter("id");

        IManager manager = new ManagerImpl();
        User user = null;
        try {
            user = manager.findUserByUserId(Integer.valueOf(userId));
        } catch (SQLException e) {
            e.printStackTrace();
        }

        req.setAttribute("user", user);
        req.getRequestDispatcher("/WEB-INF/jsp/user/admin/updateUser.jsp").forward(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
